package com.gary.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author pengrui
 * @date 2021/1/7 - 15:34
 */
@RestController
public class PaymentConsulController {

    @Value("${server.port}")
    private String port;

    private static Map<Long, String> dataMap = new HashMap<>(16);
    static {
        dataMap.put(1L, "data-1");
        dataMap.put(2L, "data-2");
        dataMap.put(3L, "data-3");
    }

    @GetMapping("/payment/consul")
    public String queryConsul() {
        return "nacos server port with " + port + "O(∩_∩)O哈哈~";
    }

    @RequestMapping(value = "/paymentSql/{id}", method = RequestMethod.GET)
    public String paymentSql(@PathVariable("id") Long id) {
        return "data { id : " + id + " value : " + dataMap.get(id) + " }, port { " + port + " }";
    }
}
